<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ page import="javax.portlet.*"%>
<%@page import="com.liferay.portal.model.User" %>
<%@page import="com.liferay.portal.util.PortalUtil" %>
<%@page import="com.jefe.hudson.service.service.*" %>
<%@page import="com.jefe.hudson.service.model.*" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<%--
Author: Sonali Mendis
Code:   Hudson Portlet for Jefe (http://www.jefesolutions.com)
License:GNU
--%>

<portlet:defineObjects />
<%
    long id = 0;
    User currentUser = null;
    try {
        currentUser = PortalUtil.getUser(request);
        id = currentUser.getUserId();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    String host = null;
    int port = 0;
    Boolean userSet = false;
    try{
        UserPrefs userDtls = UserPrefsLocalServiceUtil.getUserPrefs(id);
        host = userDtls.getHudHost();
        port = userDtls.getHudPort();
        userSet = true;
    }catch(Exception ex){
        System.out.println(ex.getMessage());
    }
%>
<div style="text-align: justify">
<strong>Hudson Portlet Guide:</strong>
<ul type="1">
    <li>
        Hudson is a popular, open source Continuous Integration server. Hudson server setup can be downloaded from the <a href="http://www.hudson-ci.org" target="_blank">Hudson Official Site</a>.
    </li>
    <li>
        A guide to configure the Hudson CI server and use it for continuous integration can be found <a href="http://sonalimendis.blogspot.com/2010/03/installing-and-configuring-hudson-ci.html" target="_blank">here</a>.
    </li>
    <li>
        The objective of this Hudson Portlet is to allow users to connect to Hudson server installed as directed above and view their Hudson jobs through Jefe.
    </li>
</ul>
<strong>Hudson Portlet Operation:</strong>
<ul>
    <li>
        Hudson server location, port, username and password are needed in the preferences for the portlet to access Hudson remotely. If security is not enabled at the Hudson server, you can omit the username and password fields.
    </li>
    <li>
        Once these information is set, the hudson remotely access the Hudson server, retrieve data for the given user and display in the view page of the portlet.
    </li>
    <li>
        Each job's last build status, name and the job URL is provided at the view page.
    </li>
    <li>
        In addition to this feature, the portlet also gives the ability to dynamically filter the accessible projects for the user.
    </li>
</ul>
</div>
<% if(userSet){%>
<hr style="border-bottom: dotted 1px"/>
<div class="portlet-section-footer" >
    More on: <a href="http://<%=host %>:<%=port %>/hudson" >Hudson</a>
</div>
<% } %>